//
//  Font+Ext.swift
//  TTProduct-iPad
//
//  Created by Toj on 1/14/21.
//

import Foundation
import CoreGraphics

fileprivate var families: [String : String] =
["RHRCN": "Resource-Han-Rounded-CN",
 "Roboto": "Roboto"]


public extension TTFont {
    enum TTName: String {
        case rhrch = "RHRCN"
        case roboto = "Roboto"
    }
}

public extension TTFont {
    /** 实际可用字重 */
    enum TTWeight: String {
        /// 细体: 300
        case light = "Light"
        /// 标准: 400
        case regular = "Regular"
        /// 适中: 500
        case medium = "Medium"
        /// 粗体: 700
        case bold = "Bold"
    }
}

public extension TTFont {
    
    convenience init?(
        name: TTName = .rhrch,
        weight: TTWeight = .regular,
        size : CGFloat
    ) {
        
        let family = families[name.rawValue] ?? ""
        let names = family + "-" + weight.rawValue
        
        self.init(name:names, size: size)
    }
}

/**
 * 全部的字重
 * 实际可用字重 请以 TTFont.TTWeight 为准
 */
enum FontWeight: String {
    /// 淡体: 100
    case thin = "Thin"
    /// 淡体: 100
    case hairline = "Hairline"
    /// 特细: 200
    case extraLight = "ExtraLight"
    /// 特细: 200
    case ultraLight = "UltraLight"
    /// 细体: 300
    case light = "Light"
    /// 次细: 350
    case demiLight = "DemiLight"
    /// 标准: 400
    case regular = "Regular"
    /// 标准: 400
    case normal = "Normal"
    /// 标准: 400
    case book = "Book"
    /// 标准: 400
    case plain = "Plain"
    /// 适中: 500
    case medium = "Medium"
    /// 次粗: 600
    case demiBold = "DemiBold"
    /// 次粗: 600
    case semiBold = "SemiBold"
    /// 粗体: 700
    case bold = "Bold"
    /// 特粗: 800
    case extra = "Extra"
    /// 特粗: 800
    case extraBold = "ExtraBold"
    /// 浓体: 900
    case black = "Black"
    /// 浓体: 900
    case heavy = "Heavy"
    /// 特浓: 950
    case extraBlack = "ExtraBlack"
    /// 特浓: 950
    case ultraBlack = "UltraBlack"
}

/**
 * 全部的字宽
 * 只是一个总结无用处
 */
enum FontWidth: String {
    /// 压缩
    case compressed
    /// 浓缩
    case condensed
    /// 扩展
    case extended
    /// 扩大
    case expanded
}

/**
 * 全部的倾斜类型
 * 只是一个总结无用处
 */
enum FontLean: String {
    case italic
    case oblique
    ///(直立意大利体)
    case uprightItalic
    /// (反向倾斜)
    case backslant
}

/**
 * 全部的视觉尺寸
 * 只是一个总结无用处
 */
enum FontOpticalSize: String {
    case display
    case text
    case caption
    case small
}
